glpk_includes = include_directories([
   '.',
   'api',
   'bflib',
   'draft',
   'env',
   'intopt',
   'minisat',
   'misc',
   'mpl',
   'npp',
   'proxy',
   'simplex',
])

glpk_sources = [
   'api/advbas.c',
   'api/asnhall.c',
   'api/asnlp.c',
   'api/asnokalg.c',
   'api/ckasn.c',
   'api/ckcnf.c',
   'api/cplex.c',
   'api/cpp.c',
   'api/cpxbas.c',
   'api/graph.c',
   'api/gridgen.c',
   'api/intfeas1.c',
   'api/maxffalg.c',
   'api/maxflp.c',
   'api/mcflp.c',
   'api/mcfokalg.c',
   'api/mcfrelax.c',
   'api/minisat1.c',
   'api/mpl.c',
   'api/mps.c',
   'api/netgen.c',
   'api/npp.c',
   'api/pript.c',
   'api/prmip.c',
   'api/prob1.c',
   'api/prob2.c',
   'api/prob3.c',
   'api/prob4.c',
   'api/prob5.c',
   'api/prrngs.c',
   'api/prsol.c',
   'api/rdasn.c',
   'api/rdcc.c',
   'api/rdcnf.c',
   'api/rdipt.c',
   'api/rdmaxf.c',
   'api/rdmcf.c',
   'api/rdmip.c',
   'api/rdprob.c',
   'api/rdsol.c',
   'api/rmfgen.c',
   'api/strong.c',
   'api/topsort.c',
   'api/weak.c',
   'api/wcliqex.c',
   'api/wrasn.c',
   'api/wrcc.c',
   'api/wrcnf.c',
   'api/wript.c',
   'api/wrmaxf.c',
   'api/wrmcf.c',
   'api/wrmip.c',
   'api/wrprob.c',
   'api/wrsol.c',
   'bflib/btf.c',
   'bflib/btfint.c',
   'bflib/fhv.c',
   'bflib/fhvint.c',
   'bflib/ifu.c',
   'bflib/luf.c',
   'bflib/lufint.c',
   'bflib/scf.c',
   'bflib/scfint.c',
   'bflib/sgf.c',
   'bflib/sva.c',
   'draft/bfd.c',
   'draft/bfx.c',
   'draft/glpapi06.c',
   'draft/glpapi07.c',
   'draft/glpapi08.c',
   'draft/glpapi09.c',
   'draft/glpapi10.c',
   'draft/glpapi12.c',
   'draft/glpapi13.c',
   'draft/glpios01.c',
   'draft/glpios02.c',
   'draft/glpios03.c',
   'draft/glpios07.c',
   'draft/glpios09.c',
   'draft/glpios11.c',
   'draft/glpios12.c',
   'draft/glpipm.c',
   'draft/glpmat.c',
   'draft/glpscl.c',
   'draft/glpssx01.c',
   'draft/glpssx02.c',
   'draft/lux.c',
   'env/alloc.c',
   'env/dlsup.c',
   'env/env.c',
   'env/error.c',
   'env/stdc.c',
   'env/stdout.c',
   'env/stream.c',
   'env/time.c',
   'env/tls.c',
   'intopt/cfg.c',
   'intopt/cfg1.c',
   'intopt/cfg2.c',
   'intopt/clqcut.c',
   'intopt/covgen.c',
   'intopt/fpump.c',
   'intopt/gmicut.c',
   'intopt/gmigen.c',
   'intopt/mirgen.c',
   'intopt/spv.c',
   'minisat/minisat.c',
   'misc/avl.c',
   'misc/bignum.c',
   'misc/dimacs.c',
   'misc/dmp.c',
   'misc/ffalg.c',
   'misc/fp2rat.c',
   'misc/fvs.c',
   'misc/gcd.c',
   'misc/hbm.c',
   'misc/jd.c',
   'misc/keller.c',
   'misc/ks.c',
   'misc/mc13d.c',
   'misc/mc21a.c',
   'misc/mt1.c',
   'misc/mygmp.c',
   'misc/okalg.c',
   'misc/qmd.c',
   'misc/relax4.c',
   'misc/rgr.c',
   'misc/rng.c',
   'misc/rng1.c',
   'misc/round2n.c',
   'misc/spm.c',
   'misc/str2int.c',
   'misc/str2num.c',
   'misc/strspx.c',
   'misc/strtrim.c',
   'misc/triang.c',
   'misc/wclique.c',
   'misc/wclique1.c',
   'mpl/mpl1.c',
   'mpl/mpl2.c',
   'mpl/mpl3.c',
   'mpl/mpl4.c',
   'mpl/mpl5.c',
   'mpl/mpl6.c',
   'mpl/mplsql.c',
   'npp/npp1.c',
   'npp/npp2.c',
   'npp/npp3.c',
   'npp/npp4.c',
   'npp/npp5.c',
   'npp/npp6.c',
   'proxy/proxy.c',
   'proxy/proxy1.c',
   'simplex/spxat.c',
   'simplex/spxchuzc.c',
   'simplex/spxchuzr.c',
   'simplex/spxlp.c',
   'simplex/spxnt.c',
   'simplex/spxprim.c',
   'simplex/spxprob.c',
   'simplex/spychuzc.c',
   'simplex/spychuzr.c',
   'simplex/spydual.c',
]

glpk_args = []
glpk_dependencies = [dependency('zlib')]

if 'SuiteSparse' in get_option('force_fallback_for') or 'forcefallback' == get_option('wrap_mode')
   glpk_dependencies += subproject('SuiteSparse').get_variable('SuiteSparse_dep')
else
   glpk_dependencies += cc.find_library('amd', required: true)
   glpk_dependencies += cc.find_library('colamd', required: true)
   glpk_args += cc.has_header('suitesparse/amd.h') ? ['-DHAVE_SUITESPARSE_AMD_H=1'] : []
   glpk_args += cc.has_header('suitesparse/colamd.h') ? ['-DHAVE_SUITESPARSE_COLAMD_H=1'] : []
endif

libglpk = static_library(
   'glpk',
   glpk_sources,
   c_args: glpk_args,
   dependencies: glpk_dependencies,
   include_directories: glpk_includes,
)
